package cn.edu.zafu.bigdata.x.zhouyuyan.work7;

public class checkAge {
    public static void checkAge(int age) throws InvalidAgeException{
        if(age<18){
            throw new InvalidAgeException("年龄必须大于或等于18");
        }else{
            System.out.println("您已经"+age+"岁了。");
        }
    }

    public static void main(String[] args){
        try{
            int testAge = 16;
            checkAge(testAge);
        }catch (InvalidAgeException e){
            System.err.println("错误:"+e.getMessage());
        }
    }
}
